<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //生成器是一个特殊的函数
        //异步编程   纯回调函数
        //yield 算作函数代码的分隔符
        function * gen(){
            console.log('hello');
            yield '一只没有耳朵';
            console.log('hello~');
            yield '一只没有尾巴';
            console.log('hello~~');
        }
        let iterator=gen();
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());

        //遍历
        // for(let v of gen()){
        //     console.log(v);
        // }
    </script>
</head>
<body>
    
</body>
</html>